package com.nbsaas.boot.marketing.rest.resource;

import com.nbsaas.boot.marketing.api.apis.PromotionApi;
import com.nbsaas.boot.marketing.data.entity.Promotion;
import com.nbsaas.boot.marketing.api.domain.request.PromotionRequest;
import com.nbsaas.boot.marketing.api.domain.response.PromotionResponse;
import com.nbsaas.boot.marketing.api.domain.simple.PromotionSimple;
import com.nbsaas.boot.marketing.rest.convert.PromotionSimpleConvert;
import com.nbsaas.boot.marketing.rest.convert.PromotionEntityConvert;
import com.nbsaas.boot.marketing.rest.convert.PromotionResponseConvert;
import com.nbsaas.boot.marketing.data.repository.PromotionRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   促销活动-业务接口实现
*/
@Transactional
@Service
public class PromotionResource extends BaseResource<Promotion,PromotionResponse, PromotionSimple, PromotionRequest>  implements PromotionApi {

    @Resource
    private PromotionRepository promotionRepository;

    @Override
    public JpaRepositoryImplementation<Promotion, Serializable> getJpaRepository() {
        return promotionRepository;
    }

    @Override
    public Function<Promotion, PromotionSimple> getConvertSimple() {
        return new PromotionSimpleConvert();
    }

    @Override
    public Function<PromotionRequest, Promotion> getConvertForm() {
        return new PromotionEntityConvert();
    }

    @Override
    public Function<Promotion, PromotionResponse> getConvertResponse() {
        return new PromotionResponseConvert();
    }




}


